Passed
Branch master (200a29)
by Sean
02:51
created

Sitemapper.initializeTimeout   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
c 0
b 0
f 0
rs 10
cc 1
1
export interface SitemapperSiteData {
2
  loc: string;
3
  lastmod?: string;
4
  priority?: string;
5
  changefreq?: string;
6
  [key: string]: any;
7
}
8
9
export interface SitemapperResponse {
10
  url: string;
11
  sites: string[] | SitemapperSiteData[];
12
  errors: SitemapperErrorData[];
13
}
14
15
export interface SitemapperErrorData {
16
  type: string;
17
  url: string;
18
  retries: number;
19
}
20
21
export interface SitemapperOptions {
22
  concurrency?: number;
23
  debug?: boolean;
24
  lastmod?: number;
25
  rejectUnauthorized?: boolean;
26
  requestHeaders?: { [name: string]: string };
27
  retries?: number;
28
  timeout?: number;
29
  url?: string;
30
  fields?: { [name: string]: boolean };
31
  proxyAgent?: any;
32
  exclusions?: RegExp[];
33
}
34
35
declare class Sitemapper {
36
  timeout: number;
37
  url: string;
38
  debug: boolean;
39
  lastmod: number;
40
  fields?: { [name: string]: boolean };
41
  requestHeaders?: { [name: string]: string };
42
  concurrency?: number;
43
  retries?: number;
44
  rejectUnauthorized?: boolean;
45
  exclusions?: RegExp[];
46
  proxyAgent?: any;
47
  timeoutTable: { [url: string]: NodeJS.Timeout };
48
49
  constructor(options?: SitemapperOptions);
50
51
  private initializeTimeout(url: string, requester: any): void;
52
  private crawl(url: string, retryIndex?: number): Promise<any>;
53
  private parse(url: string): Promise<any>;
54
  isExcluded(url: string): boolean;
55
56
  /**
57
   * Gets the sites from a sitemap.xml with a given URL
58
   *
59
   * @param url URL to the sitemap.xml file
60
   */
61
  fetch(
62
    this: Sitemapper & { fields: object },
63
    url?: string
64
  ): Promise<
65
    Omit<SitemapperResponse, 'sites'> & { sites: SitemapperSiteData[] }
66
  >;
67
  fetch(
68
    url?: string
69
  ): Promise<Omit<SitemapperResponse, 'sites'> & { sites: string[] }>;
70
71
  /**
72
   * @deprecated Use fetch() instead.
73
   */
74
  getSites(
75
    url: string | undefined,
76
    callback: (err: Error | null, sites: string[]) => void
77
  ): Promise<void>;
78
}
79
80
export default Sitemapper;
81